package playn.platformer.entities;

import playn.platformer.Entity;
import playn.platformer.Game;
import tiled.simple.core.Animation;
import tiled.simple.core.MapObject;
import tiled.simple.core.Renderer;

public class Mask implements Entity , Renderer {

	private Game game;
	
	Animation animation;

	float n=0;
	float size=1;
			
	MapObject mask;
	
	public Mask(Game game,MapObject mask) {
		this.mask=mask;
		this.game=game;
			
		n=(int) (Math.random()*10);
		size=(float) (Math.random()*3);


		if(n>5){
			animation=game.animations.getAnimation("Mask");
			
		} else {
			animation=game.animations.getAnimation("Mask&ear");
		}

	}
	
	@Override
	public void putImage(String source, int sx, int sy, int sw, int sh, int dx,int dy, int dw, int dh) {
		game.dynamicRenderer.putImage(source, sx, sy, sw, sh, mask.getX() +(int)(dx*size), mask.getY() +(int)(dy*size), (int)(dw*size)+1, (int)(dh*size)+1);
	}

	@Override
	public void render() {
		animation.renderSprite(game.animationGraphics, this, (int)n);
	}

	@Override
	public void update(float delta) {
		n+=delta/100;
	}

}
